<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <h1>{{msg}}</h1>
        <root> </root>
    </div>
    <script src="../js/vue.js"></script>
    <script>
        //创建组件
        const root = {
            template: `
            <div>
                <ul>
                    <li v-for="(user,index) of users" :key="user.id">
                        {{index}},{{user.name}}
                    </li>
               </ul>
             </div>
            `,
            data() {
                return {
                    users: [
                        { id: 001, name: 'jack' },
                        { id: 002, name: 'james' }
                    ]
                }
            }
        }
        const vm = new Vue({
            el: '#app',
            data: {
                msg: 'demo01',
            },
            // 注册组件
            components: {
                root
            }
        })
    </script>
</body>

</html>